<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <main>
        <div id="dashboard">
            <progress max="100" value="0" min="0" id="progress"></progress>
            <button class="startBtn">开始</button>
            <button class="endBtn">暂停</button>
        </div>
    </main>


    <script>
        let [startBtn,endBtn] = document.querySelectorAll('#dashboard > button')
        let state = 0
        let timer = null
        startBtn.onclick = ()=>{  
            timer = setInterval(()=>{
                state += 1
                if(state == 100){
                    clearInterval(timer)
                    return
                }
                document.querySelector('#progress').value = state
            },200)
        }
        endBtn.onclick = ()=>{
            clearInterval(timer)
        }
    </script>
</body>
</html>